﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.API.Applications.Command.DeepProcessingCommand;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.API.Controllers
{
    /// <summary>
    /// 深加工API ——控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeepController : ControllerBase
    {
        private readonly IMediator mediator;

        public DeepController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 深加工信息添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DeepProcessingAdd(DeepProcessingAddCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 深加工信息显示
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<Deep_Processing>> DeepProcessingQuery([FromQuery]DeepProcessingQueryCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 深加工企业信息添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> ProcessingPlantAdd(ProcessingPlantAddCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 深加工企业信息显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<Processing_Plant>> ProcessingPlantQuery([FromQuery]ProcessingPlantQueryCommand command)
        {
            return mediator.Send(command);
        }


    }
}
